{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### week01练习题\n",
    "#### 1.P10-11 模块查询python.org，找到每个模块使用的函数意义，作记录并运行代码\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3.8.3 (default, Jul  2 2020, 17:30:36) [MSC v.1916 64 bit (AMD64)]\n"
     ]
    }
   ],
   "source": [
    "import sys\n",
    "sys.platform\n",
    "print(sys.version)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "environ{'ALLUSERSPROFILE': 'C:\\\\ProgramData',\n",
       "        'APPDATA': 'C:\\\\Users\\\\EVA\\\\AppData\\\\Roaming',\n",
       "        'COMMONPROGRAMFILES': 'C:\\\\Program Files\\\\Common Files',\n",
       "        'COMMONPROGRAMFILES(X86)': 'C:\\\\Program Files (x86)\\\\Common Files',\n",
       "        'COMMONPROGRAMW6432': 'C:\\\\Program Files\\\\Common Files',\n",
       "        'COMPUTERNAME': 'LAPTOP-0JAEGL2E',\n",
       "        'COMSPEC': 'C:\\\\Windows\\\\system32\\\\cmd.exe',\n",
       "        'DRIVERDATA': 'C:\\\\Windows\\\\System32\\\\Drivers\\\\DriverData',\n",
       "        'HOMEDRIVE': 'C:',\n",
       "        'HOMEPATH': '\\\\Users\\\\EVA',\n",
       "        'LOCALAPPDATA': 'C:\\\\Users\\\\EVA\\\\AppData\\\\Local',\n",
       "        'LOGONSERVER': '\\\\\\\\LAPTOP-0JAEGL2E',\n",
       "        'NUMBER_OF_PROCESSORS': '8',\n",
       "        'ONEDRIVE': 'C:\\\\Users\\\\EVA\\\\OneDrive',\n",
       "        'OS': 'Windows_NT',\n",
       "        'PATH': 'C:\\\\Users\\\\EVA\\\\anaconda3;C:\\\\Users\\\\EVA\\\\anaconda3\\\\Library\\\\mingw-w64\\\\bin;C:\\\\Users\\\\EVA\\\\anaconda3\\\\Library\\\\usr\\\\bin;C:\\\\Users\\\\EVA\\\\anaconda3\\\\Library\\\\bin;C:\\\\Users\\\\EVA\\\\anaconda3\\\\Scripts;C:\\\\Program Files(x86)\\\\Python39\\\\Scripts\\\\;C:\\\\Program Files(x86)\\\\Python39\\\\;C:\\\\Windows\\\\system32;C:\\\\Windows;C:\\\\Windows\\\\System32\\\\Wbem;C:\\\\Windows\\\\System32\\\\WindowsPowerShell\\\\v1.0\\\\;C:\\\\Windows\\\\System32\\\\OpenSSH\\\\;C:\\\\Program Files (x86)\\\\NVIDIA Corporation\\\\PhysX\\\\Common;C:\\\\Program Files\\\\NVIDIA Corporation\\\\NVIDIA NvDLISR;C:\\\\Users\\\\EVA\\\\anaconda3;C:\\\\Users\\\\EVA\\\\anaconda3\\\\Library\\\\mingw-w64\\\\bin;C:\\\\Users\\\\EVA\\\\anaconda3\\\\Library\\\\usr\\\\bin;C:\\\\Users\\\\EVA\\\\anaconda3\\\\Library\\\\bin;C:\\\\Users\\\\EVA\\\\anaconda3\\\\Scripts;C:\\\\Users\\\\EVA\\\\AppData\\\\Local\\\\GitHubDesktop\\\\bin',\n",
       "        'PATHEXT': '.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY;.PYW',\n",
       "        'PROCESSOR_ARCHITECTURE': 'AMD64',\n",
       "        'PROCESSOR_IDENTIFIER': 'Intel64 Family 6 Model 142 Stepping 12, GenuineIntel',\n",
       "        'PROCESSOR_LEVEL': '6',\n",
       "        'PROCESSOR_REVISION': '8e0c',\n",
       "        'PROGRAMDATA': 'C:\\\\ProgramData',\n",
       "        'PROGRAMFILES': 'C:\\\\Program Files',\n",
       "        'PROGRAMFILES(X86)': 'C:\\\\Program Files (x86)',\n",
       "        'PROGRAMW6432': 'C:\\\\Program Files',\n",
       "        'PSMODULEPATH': 'C:\\\\Program Files\\\\WindowsPowerShell\\\\Modules;C:\\\\Windows\\\\system32\\\\WindowsPowerShell\\\\v1.0\\\\Modules',\n",
       "        'PUBLIC': 'C:\\\\Users\\\\Public',\n",
       "        'SESSIONNAME': 'Console',\n",
       "        'SYSTEMDRIVE': 'C:',\n",
       "        'SYSTEMROOT': 'C:\\\\Windows',\n",
       "        'TEMP': 'C:\\\\Users\\\\EVA\\\\AppData\\\\Local\\\\Temp',\n",
       "        'TMP': 'C:\\\\Users\\\\EVA\\\\AppData\\\\Local\\\\Temp',\n",
       "        'USERDOMAIN': 'LAPTOP-0JAEGL2E',\n",
       "        'USERDOMAIN_ROAMINGPROFILE': 'LAPTOP-0JAEGL2E',\n",
       "        'USERNAME': 'EVA',\n",
       "        'USERPROFILE': 'C:\\\\Users\\\\EVA',\n",
       "        'WINDIR': 'C:\\\\Windows',\n",
       "        'CONDA_PREFIX': 'C:\\\\Users\\\\EVA\\\\anaconda3',\n",
       "        'KERNEL_LAUNCH_TIMEOUT': '40',\n",
       "        'JPY_INTERRUPT_EVENT': '2344',\n",
       "        'IPY_INTERRUPT_EVENT': '2344',\n",
       "        'JPY_PARENT_PID': '2256',\n",
       "        'TERM': 'xterm-color',\n",
       "        'CLICOLOR': '1',\n",
       "        'PAGER': 'cat',\n",
       "        'GIT_PAGER': 'cat',\n",
       "        'MPLBACKEND': 'module://ipykernel.pylab.backend_inline'}"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import os\n",
    "os.getcwd()\n",
    "os.environ"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.date(2020, 10, 13)"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import datetime\n",
    "datetime.date.today()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "13"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "datetime.date.today().day"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "10"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "datetime.date.today().month"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2020"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "datetime.date.today().year"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'12:40'"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import time\n",
    "time.strftime(\"%H:%M\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### ②尝试理解if 、else、elif是什么？什么是代码块，并运行P16-18代码"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* If：如果条件为真，执行子句中的代码。\n",
    "* else：一是只有if语句条件为False时，else子句才会执法；二是如果条件为真，执行这段代码,否则执法那段代码；三是else语句不包含代码。\n",
    "* elif：一是“否则如果”，它总是跟在if或另一条elif语句后面；二是它提供了另一个条件，仅仅是在前面的条件为False时才检查该条件。\n",
    "* 代码块：一个模块，一个函数，一个类，一个文件等都是一个代码块。而作为交互方式输入的每个命令都是一个代码块。\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "This minute seems a little odd.\n"
     ]
    }
   ],
   "source": [
    "from datetime import datetime\n",
    "odds = [1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59]\n",
    "right_this_minute = datetime.today().minute\n",
    "if right_this_minute in odds:\n",
    "    print(\"This minute seems a little odd.\")\n",
    "else:\n",
    "    print(\"Not an odd minute.\")\n",
    "    \n",
    "from datetime import datetime"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "work!\n"
     ]
    }
   ],
   "source": [
    "import datetime\n",
    "today=datetime.datetime.today().weekday()\n",
    "if today==\"saturday\":\n",
    "    print(\"wow!\")\n",
    "if today==\"sunday\":\n",
    "    print(\"year!\")\n",
    "else:\n",
    "    print(\"work!\")\n",
    "    \n",
    "from datetime import datetime    "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### ③尝试理解什么是迭代，并运行P24-25 for循环、range循环代码，互相讨论其用法\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "迭代：python中的迭代是指通过重复执行的代码处理相似的数据集的过程，并且本次迭代的处理数据要依赖上一次的结果继续往下做。上一次产生的结果为下一次产生结果的初始状态，如果中途有任何停顿，都不能算是迭代。\n",
    "循环代码：for循环可以依次把list或tuple的每个元素依次列出来，range则可以循环复制相同的内容，它们可以结合使用。\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "2\n",
      "3\n"
     ]
    }
   ],
   "source": [
    "for i in[1,2,3]:\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "T\n",
      "r\n",
      "e\n",
      "v\n",
      "o\n",
      "r\n"
     ]
    }
   ],
   "source": [
    "for who in \"Trevor\":\n",
    "    print(who)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "你好帅哦！！！\n",
      "你好帅哦！！！\n",
      "你好帅哦！！！\n",
      "你好帅哦！！！\n",
      "你好帅哦！！！\n",
      "你好帅哦！！！\n",
      "你好帅哦！！！\n",
      "你好帅哦！！！\n"
     ]
    }
   ],
   "source": [
    "for num in range(8):\n",
    "    print(\"你好帅哦！！！\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
